home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 4690 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.4 KB

  1. Path: news.cencom.net!ns!tanp
  2. From: tanp@ns (Bill Wendling)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: #define, question from a beginner
  5. Date: 6 Feb 1996 07:04:58 GMT
  6. Organization: Cen-Com Internet
  7. Message-ID: <4f6uiq$rt1@news.cencom.net>
  8. References: <ma-010296161301@mac147.maths.uwa.edu.au> <31109AF8.423B@zess.uni-siegen.de> <TANMOY.96Feb1095641@qcd.lanl.gov> <31165CA1.2781E494@texas.net>
  9. NNTP-Posting-Host: ns.cencom.net
  10. X-Newsreader: TIN [version 1.2 PL2]
  11.  
  12. Michael Douglass inexplicably wrote:
  13. } What I'm trying to figure out is *why* you want to include comments
  14. } inside of a macro anyways...  The only thing that would see the expanded
  15. } version w/ comments would be the compiler after preprocessing... Which
  16. } would then barf on comments because the preprocessor takes the comments
  17. } out... (Doesn't it?)
  18.  
  19. You want to be careful when putting comments into a macro.  Take, for
  20. instance, this (comments in C++, but the example's comments were in 
  21. C++ sooo..):
  22.  
  23. #define MACRO    printf("%d ", j); //cmnt \
  24.             /*cmnt*/       \
  25.         printf("%d", k);  //cmnt.
  26.  
  27. This macro will expand to:
  28.  
  29. printf("%d ", j);    //cmnt /*cmnt */ printf("%d", k);  //cmnt.
  30.  
  31. And you will only be printing out the value of j.
  32.  
  33. --
  34. Bill Wendling         | "Pinky, are you thinking what I'm thinking?"
  35. tanp@ns.cencom.net  | "I think so, Brain, but burlap chafes me so."
  36. "Boom Shanka"       | Finger me for my Geek Code...NOW!
  37.